import request from '@/utils/request'

const API_NAME = '/admin/system/sysUser'

export default {
    // 分页查询用户信息
    getPageList(page, limit, searchObj) {
        return request({
            url: `${API_NAME}/${page}/${limit}`,
            method: 'get',
            params: searchObj
        })
    },
    // 根据用户id查询用户信息
    getUserById(id) {
        return request({
            url: `${API_NAME}/get/${id}`,
            method: 'get',
        })
    },
    // 添加用户信息
    saveUser(userObj) {
        return request({
            url: `${API_NAME}/save`,
            method: 'post',
            data: userObj
        })
    },
    // 修改用户信息
    updateUser(userObj) {
        return request({
            url: `${API_NAME}/update`,
            method: 'put',
            data: userObj
        })
    },
    // 根据id删除用户信息
    removeUseById(id) {
        return request({
            url: `${API_NAME}/delete/${id}`,
            method: 'delete',
        })
    },
    // 修改用户状态
    updateUserStatus(id, statusCode) {
        return request({
            url: `${API_NAME}/updateStatus/${id}/${statusCode}`,
            method: 'put'
        })
    },
    //根据用户id查询用户已分配的角色
    getRolesByUserId(userId) {
        return request({
            url: `${API_NAME}/toAssign/${userId}`,
            method: 'get'
        })
    },

    //分配角色
    assignRoles(assginRoleVo) {
        return request({
            url: `${API_NAME}/doAssign`,
            method: 'put',
            data: assginRoleVo
        })
    }
}
